<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="姜启航">
    <title></title>
    <style>
        body{
            width: 100vh;
            height: 100vh;
        }
        .box{
            width: 500px;
            display: flex;
        }
    .xuanze{
        width: 80px;
        height: 25px;
        margin: 0;
        /* border: 1px solid palegreen; */
        background-color: palegreen;
    }
    ul{
        margin: 0;
        padding: 0;
        list-style: none;
        margin-top: 25px;
        margin-left: -50px;
        display: none;
  
    }
    ul>li{
        width: 48px;
        height: 23px;
        border: 1px dotted #ccc;
        text-align: center;
    }
  a{
        color: #000;
        text-decoration: none;
    }
    .div-a{
        width: 50px;
        background-color: #aaa;
        height: 25px;
        text-align: center;
    }
    /* ul>li:first-child{
        background-color: #aaa;
        display: block;
        
    } */
    </style>
</head>
<body>
    <div class="box">
        <div class="xuanze">选择项目：</div>
        <div class="div-a"><a href="#">未选择</a></div>
    <ul>
        <li><a href="#">html5</a></li>
        <li><a href="#">css3</a></li>
        <li><a href="#">js</a></li>
        <li><a href="#">jq</a></li>
    </ul>
    </div>
    
    <script src="../jquery.js"></script>
</body>
</html>

<script>
$('.div-a').click(function(ev){
    // 阻止事件冒泡
    ev.stopPropagation();
    $('ul').css('display','block');
})
$('li').click(function(){
    $('.div-a').html($(this).html())
    console.log($('.div-a').html());
    
})
$('body').click(function(){
    $('ul').css('display','none');
})
$('li').mouseover(function(){
    $(this).css('background-color','#aaa');
})
$('li').mouseout(function(){
    $(this).css('background-color','#fff');
})







</script>